// s.r(t),
//   s.d(t, {
//     RenderPass: () => RenderPass,
//   });
import * as THREE from "three"
import { Pass } from "./Pass"
export default class RenderPass extends Pass {
  scene: THREE.Scene
  camera: THREE.PerspectiveCamera
  overrideMaterial: THREE.Material
  clearColor: THREE.Color
  clearAlpha: number
  clearDepth: boolean
  _oldClearColor: THREE.Color
  constructor(e, t, s?, i?, a?) {
    super()
    this.scene = e
    this.camera = t
    this.overrideMaterial = s
    this.clearColor = i
    this.clearAlpha = void 0 !== a ? a : 0
    this.clear = !0
    this.clearDepth = !1
    this.needsSwap = !1
    this._oldClearColor = new THREE.Color()
  }
  render(e: THREE.WebGLRenderer | THREE.WebGL1Renderer, t: THREE.WebGLRenderTarget, s: THREE.WebGLRenderTarget) {
    const r = e.autoClear
    let i: number, a: THREE.Material
    e.autoClear = !1
    void 0 !== this.overrideMaterial && ((a = this.scene.overrideMaterial), (this.scene.overrideMaterial = this.overrideMaterial))
    this.clearColor && (e.getClearColor(this._oldClearColor), (i = e.getClearAlpha()), e.setClearColor(this.clearColor, this.clearAlpha))
    this.clearDepth && e.clearDepth()
    e.setRenderTarget(this.renderToScreen ? null : s)
    this.clear && e.clear(e.autoClearColor, e.autoClearDepth, e.autoClearStencil)
    e.render(this.scene, this.camera)
    this.clearColor && e.setClearColor(this._oldClearColor, i)
    void 0 !== this.overrideMaterial && (this.scene.overrideMaterial = a)
    e.autoClear = r
  }
}
